﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace PACKETPARSERMAX20.CORE
{
    public class OpcodeFilter : System.Collections.Generic.List<Opcodes>
    {

        public OpcodeFilter()
        {
            LoadDefaults();
        }

   
        public void LoadDefaults()
        {
            base.Clear();

            base.Add(Opcodes.CMSG_WHO);
            base.Add(Opcodes.SMSG_WHO);

            base.Add(Opcodes.CMSG_PING);
            base.Add(Opcodes.SMSG_PONG);

            base.Add(Opcodes.CMSG_WARDEN_DATA);
            base.Add(Opcodes.SMSG_WARDEN_DATA);

            base.Add(Opcodes.CMSG_QUERY_TIME);
            base.Add(Opcodes.CMSG_PLAYED_TIME);


        }

        public FILTER_STATE ProcessFilter(Opcodes opcode)
        {

            if (base.Contains(opcode))
            {
                return FILTER_STATE.SKIP;
            }
            else if (((int)opcode) > (int)Opcodes.NUM_MSG_TYPES)
            {
                return FILTER_STATE.BEYOND;
            }
            else
            {
                return FILTER_STATE.USE;
            }

        }

    }

}
